﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI.HtmlControls;

namespace SoftballStats
{
    public partial class SelectSeason : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetSeasons();
        }

        public void GetSeasons()
        {
            List<SoftballStats_BL.Season> lstSeasons = new List<SoftballStats_BL.Season>();
            lstSeasons = SoftballStats_BL.Season.GetSeasons();

            for (int i = 0; i < lstSeasons.Count; i++)
            {
                HtmlTableRow tblRow = new HtmlTableRow();

                HtmlTableCell tblCell = new HtmlTableCell();
                LinkButton lnkSelect = new LinkButton();
                lnkSelect.Text = "Select";
                lnkSelect.PostBackUrl = "~/Default.aspx?SeasonID=" + lstSeasons[i].ID.ToString();
                tblCell.Controls.Add(lnkSelect);
                tblRow.Cells.Add(tblCell);

                HtmlTableCell tblCell2 = new HtmlTableCell();
                Label lblYear = new Label();
                lblYear.Text = lstSeasons[i].Year.ToString();
                tblCell2.Controls.Add(lblYear);
                tblRow.Cells.Add(tblCell2);

                HtmlTableCell tblCell3 = new HtmlTableCell();
                Label lblDescription = new Label();
                lblDescription.Text = lstSeasons[i].Description;
                tblCell3.Controls.Add(lblDescription);
                tblRow.Cells.Add(tblCell3);

                HtmlTableCell tblCell4 = new HtmlTableCell();
                Label lblID = new Label();
                lblID.Text = lstSeasons[i].ID.ToString();
                tblCell4.Controls.Add(lblID);
                tblRow.Cells.Add(tblCell4);
                tblRow.Cells[3].Style.Add("display", "none");

                tblSeasons.Rows.Add(tblRow);
            }
        }
    }
}